package ar.uba.fi.taller2.ftrs.parser;

import ar.uba.fi.taller2.ftrs.index.Indexador;

public class DocumentParser {
	/*
	private String doc;
	private String location;
	private String description;
	
	public DocumentParser() {}
	
	public void setDocumentName(String s){
		this.doc = s;
	}
	public String getDocumentName(){
		return this.doc;
	}
	
	public String getDocumentLocation(){
		return this.location;
	}	
	public void setDocumentLocation(String s){
		this.location = s;
	}
	
	public String getDocumentDescription(){
		return this.description;
	}	
	public void readDocumentDescription(){
		this.description = "Leer del Documento";
	}
	public void setDocumentDescription(String s){
		this.description = s;
	}	
	
	*/	
	public static void parseDocument(String path) throws Exception {
		Indexador indexador = Indexador.getIndexador();
		indexador.nuevoDocumento(path);
		Parser parser;
		
		if ( path.endsWith(".txt") ) parser = new TextParser(path);
			else if ( path.endsWith(".html") ) parser = new HtmlParser(path);
				else if ( path.endsWith(".pdf") ) parser = new PdfParser(path);
					else if ( path.endsWith(".doc") ) parser = new WordParser(path);
						else throw new Exception("Sufijo de Archivo Desconocido");
		try{
			parser.parsear();
		}
		catch( Exception e){
			throw new Exception(" Error Parseando Documento :" + e );
		}
		
	}
	
	public static void main(String args[]) {
		
		String document = "/tmp/test.pdf";
		
		try{
			DocumentParser.parseDocument(document);
		}
		catch(Exception e){
			System.out.println(e);
		}
	}
}
